package com.gxar.quick.ar.server.base.model.protocol;

import com.gxar.common.utils.AssemblerUtils2;
import com.gxar.common.utils.AssertUtils;
import com.gxar.quick.ar.server.base.model.ResultCodeEnum;
import com.gxar.quick.ar.server.db.model.WorksEntity;
import lombok.Data;

/**
 * 通用输入作品信息
 *
 * @author zxh
 * @version 1.0
 * @created 2024/02/22 15:44
 */
@Data
public class CommonInputWorkInfo {

    private String worksId;

    private String identify;

    private String content;

    private String editor;

    private Integer productionMethod;

    private Integer watermark;

    public static CommonInputWorkInfo from(Object inputWork) {
        AssertUtils.notNull(inputWork, ResultCodeEnum.CONVERT_PROTOCOL_PARAM_ERROR);

        return AssemblerUtils2.assemble(inputWork, CommonInputWorkInfo.class);
    }

    public static CommonInputWorkInfo from(WorksEntity inputWork) {
        AssertUtils.notNull(inputWork, ResultCodeEnum.CONVERT_PROTOCOL_PARAM_ERROR);

        CommonInputWorkInfo commonWorkInfo = new CommonInputWorkInfo();
        commonWorkInfo.setWorksId(inputWork.getId().toString());
        commonWorkInfo.setEditor(inputWork.getEditor());
        commonWorkInfo.setProductionMethod(inputWork.getProductionMethod());
        commonWorkInfo.setIdentify(inputWork.getIdentify());
        commonWorkInfo.setContent(inputWork.getContent());
        return commonWorkInfo;
    }

}
